package com.easy.sys.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easy.common.bean.SysPermission;
import com.easy.common.service.IPermissionService;
import com.easy.sys.mapper.SysMenuMapper;
import com.easy.sys.mapper.SysPermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysPermissionService implements IPermissionService {
    @Autowired
    SysPermissionMapper sysPermissionMapper;

    @Override
    public SysPermission insert(SysPermission sysPermission) {
        sysPermissionMapper.insert(sysPermission);
        SysPermission result=this.getByID(sysPermission.getId());
        return result;
    }

    @Override
    public SysPermission update(SysPermission sysPermission) {
        sysPermissionMapper.updateById(sysPermission);
        SysPermission result=this.getByID(sysPermission.getId());
        return result;
    }

    @Override
    public int delete(Integer id) {
        int result=sysPermissionMapper.deleteById(id);
        return result;
    }

    @Override
    public SysPermission getByID(Integer id) {
        SysPermission result=sysPermissionMapper.selectById(id);
        return result;
    }

    @Override
    public IPage<SysPermission> getListByPage(IPage page, SysPermission sysPermission) {
        Wrapper wrapper = new QueryWrapper(sysPermission);
        IPage<SysPermission> result=sysPermissionMapper.selectPage(page, wrapper);
        return result;
    }

    @Override
    public List<SysPermission> getList(SysPermission sysPermission) {
        Wrapper wrapper = new QueryWrapper(sysPermission);
        List<SysPermission> result=sysPermissionMapper.selectList(wrapper);
        return result;
    }
}
